<?php

include_once($ROOT . "base.inc.php");

class PageController extends BaseController {

  var $event;
  var $contact;
  var $location;
  var $setlistSongs;

  function PageController() {
	parent::__construct();

	$this->title = "Event";
	$this->section = "events";

	$action = $this->getParameter("action");
	$this->event = new Event();
	$this->contact = new Contact();
	$this->location = new Location();

	switch (strtoupper($action))
	{
		case "LOAD" :
			  $id = $this->getParameter("id");
	  		  $this->event = EventLogic::load($id);
	  		  $this->contact = ContactLogic::load($this->event->contact_id);
	  		  $this->location = LocationLogic::load($this->event->location_id);
	  		  $this->setlistSongs = EventLogic::loadSetlist($id);
	  		  break;
	  	default :
	}

	$this->events = EventLogic::findAll();
	$this->contacts = ContactLogic::findAll();
	$this->locations = LocationLogic::findAll();

  }

  function parseForm() {
  	$this->event->pubilc = "F";
  	$this->event->readForm();
  	$this->contact->readForm();
  	$this->contact->id = $this->getParameter("contact_id");
  	$this->contact->address_id = $this->getParameter("contact_address_id");
  	$this->location->readForm();
  	$this->location->id = $this->getParameter("location_id");
  	if (strlen($address = $this->getParameter("address_id")) > 0)
  	{
	  	$this->locationAddress->readForm();
  	}
  	else
  	{
  		$this->locationAddress->id = $this->getParameter("location_address_id");
  	}
  }

  function validate() {
	return (sizeof($this->errs) == 0);
  }

}



?>
